package JLB_Chapter_05;
// Jerque
public class code_05_40 {
    public static void main(String[] args) {
        // String循环10000次的结果
        String str = "";
        long startTime = System.currentTimeMillis();
        for(int  i = 0; i < 10000; i++) {
            str = str + i;
        }
        long endTime = System.currentTimeMillis();
        long time = endTime - startTime;
        System.out.println(time);
        // StringBuilder 循环10000次的结果
        StringBuilder builder = new StringBuilder("");
        startTime = System.currentTimeMillis();
        for(int i = 0; i < 10000; i++) {
            builder.append(i);
        }
        endTime = System.currentTimeMillis();
        time = endTime - startTime;
        System.out.println(time);
        // StringBuffer循环10000次的结果
        StringBuffer buffer = new StringBuffer("");
        startTime = System.currentTimeMillis();
        for(int i = 0; i < 10000; i++) {
            buffer.append(i);
        }
        endTime = System.currentTimeMillis();
        time = endTime - startTime;
        System.out.println(time);
    }
}
